package com.bytedance.frameworks.a.a;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;

import com.bytedance.frameworks.base.mvp.Presenter;
import com.bytedance.frameworks.base.mvp.View;

public abstract class b<P extends Presenter>  extends BaseNewDetailActivity
        implements View {
    public P mPresenter;

    public b() {

    }

    @NonNull public abstract P createPresenter(Context context);

    protected final void beforeSuperOnCreate(Bundle bundle) {
        if(this.mPresenter == null) {
            this.mPresenter = this.createPresenter(this);
        }
        this.mPresenter.setView(this);
        this.mPresenter.onCreate(this.getIntent().getExtras(), bundle);
    }

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        this.mPresenter.onActivityResult(requestCode, resultCode, data);
    }

    public void onDestroy() {
        super.onDestroy();
        this.mPresenter.onDestroy();
        this.mPresenter.releaseView();
    }

    public void onPause() {
        super.onPause();
        this.mPresenter.onPause();
    }

    public void onResume() {
        super.onResume();
        this.mPresenter.onResume();
    }

    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
    }

    public void onStart() {
        super.onStart();
    }

    public void onStop() {
        super.onStop();
    }
}

